use edge_gateway::config::load_config;

#[test]
fn test_cfg_file() {
    // 配置文件路径
    let path = "config/config.yml";

    // 调用读取函数
    let cfg = load_config(path).expect("Failed to load config file...");
    // 测试就直接使用 print
    println!("{:#?}", cfg);

    // 自测断言
    // 1. 网关内容断言
    assert!(!cfg.gateway.id.is_empty(), "Gateway id shouldn't be empty...");
    assert!(cfg.gateway.poll_interval_ms > 0, "Poll interval must greater than zero...");
    assert!(!cfg.modbus.slaves.is_empty(), "Should have at least one mudbus slave...");

    // 2. modbus从站配置断言
    for s in &cfg.modbus.slaves {
        assert!(!s.name.is_empty(), "Slave name missing...");
        assert!(!s.addr.is_empty(), "Slave address missing...");
        assert!(s.reg_count > 0, "Slave register count must greater than zero...");
    }
}